﻿namespace AntdUI_HamburgerMenuTabs
{
    /// <summary>
    /// 日志扩展类
    /// 作者：紫剑一品箫
    /// 日期：2025-07-31
    /// </summary>
    public static class LogExtentions
    {
        private readonly static Queue<string> logs = new();
        private readonly static Lock lk = new();
        /// <summary>
        /// 日志消息压入队列
        /// </summary>
        /// <param name="log"></param>
        /// <returns></returns>
        public static bool LogEnqueue(this string log)
        {
            lock (lk)
            {
                logs.Enqueue(log);
                return true;
            }
        }

        /// <summary>
        /// 日志消息弹出队列
        /// </summary>
        /// <returns></returns>
        public static string? LogDequeue()
        {
            lock (lk)
            {
                if (logs.Count > 0)
                {
                    return logs.Dequeue();
                }
                return null;
            }
        }

        /// <summary>
        /// 在 Visual Studio 输出窗口打印调试日志
        /// </summary>
        /// <param name="log"></param>
        public static void DebugLog(this string log)
        {
            System.Diagnostics.Debug.Print($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.ffffff}] {log}");
        }
    }
}